<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<% String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
	<div class="Wrapper">
		<div>
			<form id="ligerForm">
				<div class="fieldset1 tabel_col clearFix">
				<div class="btnsBox">
					<span id="saveBtn" class="sq-button sq-button-round" onclick="save();">保存</span>
					 <span id="closeBtn" class="sq-button sq-button-round" onclick="Remove_navTab();">关闭</span> 
				</div>
					<div class="caption">
						<span class="title">基本信息</span>
					</div>
					<div class="fieldBox col_33">
						<div class="label">名称</div>
						<div class="field">
							<input id="listName"  name="listName"  value="${entity.listName}"  type="text"   class="ui-textbox"  ligerui="width: 160">
							<span class="requiredSymbol">*</span>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">备注</div>
						<div class="field">
							<input id="memo"  name="memo"  value="${entity.memo}"  type="text"   class="ui-textbox"  ligerui="width: 160">
						</div>
					</div>
					<div class="caption">
						<span class="title">条件</span>
					</div>
					
					<div class="fieldBox col_33">
						<div class="label">权证类别</div>
						<div class="field">
							<select id="warrantType"  name="warrantType"  ligerui="width: 160">
									<option value="">请选择</option>
									<c:forEach items="${warrantTypeList}" var="item">
										<option value="${item.key}" >${item.value}</option>
									</c:forEach>
								</select>
							<span class="requiredSymbol">*</span>
						</div>
					</div>
					
					<div class="caption">
						<span class="title">明细</span>
					</div>
					
					<div class="fieldBox col_100">
						<div style="width: 98%; margin-left: 1%;">
							<div id="ligergrid1" class="sq-grid"></div>
						</div>
					</div>
					
				</div>
				
				<div class="btnsBox">
					<span id="saveBtn" class="sq-button sq-button-round" onclick="save();">保存</span>
					<span id="closeBtn" class="sq-button sq-button-round" onclick="Remove_navTab();">关闭</span>
				</div>
			</form>
		</div>
	</div>
	<script type="text/javascript">
		$(function() {
			$("#ligerForm").ligerForm({
				validate: true
			});
			initGrid();//初始化明细
			initBuOrgCd();
			liger.get("warrantType").selectValue("${entity.warrantType}");//权证类别
			liger.get("warrantGrade").selectValue("${entity.warrantGrade}");//权证级别
			liger.get("arcLevel").selectValue("${entity.arcLevel}");//归类级别
	    });
	
		//初始化事业部
		function initBuOrgCd(){
			$("#buOrgCd").ligerComboBox({ 
				url: '<%=path%>/ass/asspackinfo/getbuOrgCd.do',
				ajaxType :'GET',
	            slide: false,
	            selectBoxHeight: 200,
	            valueField: 'key', 
	            textField: 'value',
	            isMultiSelect: true
	        });
		}
		
		//初始化明细
		function initGrid(){
			$("#ligergrid1").ligerGrid({
				url:'<%=path%>/archive/arcBscInfo/searchList.do',
				method:'get',
				//parms:getSearchParams(),
				columns:[
					{ display: '权证类别', name: 'warrantType'},
					{ display: '权证名称', name: 'warrantName'},
					{ display: '权证级别', name: 'warrantGrade'},
					{display:'原件/复印件/电子',render:function (rowdata, rowindex, value){
							var h="";//checked="checked" 
				            	h+='<input name="type'+rowindex+'"  value="0" type="radio"> 原件';
				            	h+='<input name="type'+rowindex+'"  value="1" type="radio"> 复印件';
				            	h+='<input name="type'+rowindex+'"  value="2" type="radio"> 电子';
							
							return h;
						}
					},{display:'是否必选',render:function (rowdata, rowindex, value){
							var h="";
								h+='<input name="ischoice'+rowindex+'" value="0" type="radio"> 必选';
				            	h+='<input name="ischoice'+rowindex+'" value="1" type="radio"> 非必选';
					
							return h;
						}
					},{display:'原件/复印件/电子',render:function (rowdata, rowindex, value){
								var h="";
								h+='<input name="fenshu'+rowindex+'" id="fenshu'+rowindex+'" value="0" type="text" style="width:40px"> 份';
					
							return h;
						}
					}
				],
				usePager: false,//是否有分页便签
				isScroll: true,//是否有滚动条
				//pageSize:10,
				root:'rows',
				record:'total',
				hideLoadButton:false,
				width:'100%',
				//height:'100%',
				heightDiff:-2,
				checkbox:true,//列表是否有选择框
				rownumbers:true,//列表是否有行号
				selectRowButtonOnly:true,//复选框模式时，是否只允许点击复选框才能选择行
				//选择行事件
				onSelectRow: function(rowdata, rowid, rowobj){
					
				},
				//取消选择行事件
				onUnSelectRow : function(rowdata, rowid, rowobj){
					
				}
			});
			grid = liger.get("ligergrid1");
			//grid.setHeight(10);
			//grid.options.isSingleCheck = true;//列表是否为单选
		}
		
		//保存
		function save(){
			var ligerForm = liger.get("ligerForm");
			if (!ligerForm.valid()) {
				$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
				return false; 
			}
			
			
			if($.trim($("#listName").val()) == ""){
				$.ligerDialog.SQalert({content: "请填写名称",SQ_type: "warning"});
				return false;
			}
			
			var _warrantType = liger.get("warrantType");
			var warrantType = _warrantType.getValue();
			if(!warrantType){
				$.ligerDialog.SQalert({content: "请选择权证类别！",SQ_type: "warning"});
				return false;
			}
			
			var _warrantGrade = liger.get("warrantGrade");
			var warrantGrade = _warrantGrade.getValue();
			if(!warrantGrade){
				$.ligerDialog.SQalert({content: "请选择权证级别！",SQ_type: "warning"});
				return false;
			}
			
			var data = ligerForm.getData();//获取表单数据
			//data["warrantType"] = warrantType;
			
		
			var wait_dialog = null;
			var id="${entity.id}";
			$.ajax({
				type: 'post',
				dataType: 'json',
				data: data,
				url: '<%=path%>/archive/arcBscInfo/save.do?id='+id,
				beforeSend: function(){
					wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
				},
				success:function(msg){
					wait_dialog.close();
					if(msg.success == 1){
							$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
							if(id == "") {
								Remove_navTab();//新增，关闭当前页面
							}
					}else{
						$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					}
				}
			});
		}
		
	</script>
</body>
</html>